﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
/*
OOP Practice v1.2
- v1.2 - Exception Handling
- v1.1 - All Tasks for Tuesday

 */
namespace Individualtask
{
    class Program
    {
        static void Main(string[] args)
        {
            Movie m1 = new Movie()
            {
                //Title = "Avengers",
                Genre = "ET",
                Year = 1985
            };
            m1.GetDvd();
            Movie m2 = new Movie() { Genre = "Comedy", Year = 2015, Title = "Waterboy pt Duex" };
            m2.GetDvd();


            Actor a1 = new Actor() {
                Name = "John Wayne",
                Age = 87,
                HasAward = true
            };
            IceCream i1 = new IceCream("chocolate",8000)
            {
                //Flavor = "Vanilla",
                //Calories = 500,
                //HasNuts = false
            };

            Student s1 = new Student();
            Student s2 = new Student("Josh", 99.9);
            Student s3 = new Student("Bill", 45.6);
           
            Student s4 = new Student(85.8, "dec 25th");
            s4.City = "Not San Antonio!";
            s4.GetFinalGrade();
            //Student s5 = new Student("Name":"Sam");

            Courses.AddCourse("Yoga");
            List<string> myList = Courses.GetCourses();
            foreach (string item in myList)
            {
                Console.WriteLine(item);
            }


            #region output class details 
            PropertyInfo[] OutputDetails = m1.GetType().GetProperties();

            foreach (PropertyInfo item in OutputDetails)
            {
                //Console.WriteLine("{0}, {1}", 
                //    item.Name,
                //    item.GetValue(m1, null)); 
            }
            PropertyInfo[] Jelly = a1.GetType().GetProperties();

            foreach (PropertyInfo item in Jelly)
            {
                //Console.WriteLine("Actor {0} = {1}",
                //    item.Name,
                //    item.GetValue(a1, null));
            }
            PropertyInfo[] Peanuts = i1.GetType().GetProperties();

            foreach (PropertyInfo item in Peanuts)
            {
                //Console.WriteLine("My favorite icecream is {0} = {1}", item.Name, item.GetValue(i1, null));
            }

            // List
            List<int> intList = new List<int>();
            List<int> intList2 = new List<int>() { 4, 5, 6, 7 };
            intList2.Add(12);

            IceCream i2 = new IceCream("Rum Raisin", 10);
            List<IceCream> flavors = new List<IceCream>();
            flavors.Add(i1);
            flavors.Add(i2);

            foreach (IceCream item in flavors)
            {
                //Console.WriteLine("Ice Cream flavor: {0} has {1} colories, and has nuts = {2}",
                //    item.Flavor, item.Calories, item.HasNuts);
            }

            #endregion

            Console.ReadLine();
        }
    }
// Static
    static class Courses
    {
        public static List<string> CourseList = new List<string>() { "C#", "JS", "HoloLens" };

        static public List<string> GetCourses()
        {
            return CourseList;
        }
        static public void AddCourse(string courseToAdd){
            CourseList.Add(courseToAdd);
        }


    }




    // Inheritance
    public class RootLevel
    {
        public virtual string City { get; set; } // where thye are from
    }
    public class AuditObject : RootLevel
    {
        public string DateStart { get; set; } // date they started program
        public string DateBirth { get; set; } // date of birth

        public AuditObject(string DateOfBirth)
        {
            this.DateBirth = DateOfBirth;
        }
    }

    public class Student : AuditObject
    {
        public string Name { get; set; }
        public string School { get; set; }
        public double GradeAverage { get; set; }

        private int _finalGrade; // hiding data

        // Encapsulation....
        public int GetFinalGrade()
        {
            return _finalGrade; // private
        }
        public void SetFinalGrade(int gradeValueToSet)
        {
            if (gradeValueToSet >= 100)
            {
                Console.WriteLine("can not do that. grade to high!");
            }
            else
            {
                _finalGrade = gradeValueToSet;
            }
            
        }


        // Constructor...
        public Student() : base ("fri 13th")
        {
            this.Name = "Adam Sandler";
            this.GradeAverage = 65.5;
        }
        // Overload Constructor 2 args...
        public Student(string studentName, double studentGrade) : base("wed 29th")
        {
            this.Name = studentName;
            this.GradeAverage = studentGrade;
        }
        // Overload Constructor 1 arg...
        public Student(double studentGrade, string UsedForDate)
            : base(UsedForDate)
        {
            this.GradeAverage = studentGrade;
        }
        // Overload Constructor 1 arg...
        public Student(string studentName)
            : base("wed 29th")
        {
            this.Name = studentName;
        }
        //
        public Student(string school)
            : base("wed 29th")
        {
            this.School = school;
        }

    }


    public class Movie {
        public string Title { get; set; }
        public string Genre { get; set; }
        public int Year     { get; set; }

        // SIMPLE EXCEPTION HANDLING....
        // check if dvd is avaialbe for movie based on year released
        public void GetDvd()
        {
            // dynamically get the year
            DateTime dt = DateTime.Now; // Get the date and time for the current moment
            //new DateTime(); // specified
            //Console.WriteLine("Current Year: {0}", dt.Year );

            if (dt.Year <= this.Year)
            { 
                
                //Console.WriteLine("The DVD is not out yet.");
                Exception ex = new Exception(string.Format("The DVD is not out yet."));
                ex.HelpLink = "http://www.buildwindows.com/";
                ex.Data.Add("Reason", "Its still in the theaters or not even created yet!");
              //  throw ex;
            } else {
                Console.WriteLine("The DVD should be avialable.");

            }
        }


        // Constructor....
        public Movie() {
            this.Title = "Mad Max: Fury Road";
            this.Genre = "Action";
            this.Year = 2015;
        }
    }



    public class Actor : AuditObject
    {
        public string Name { get; set; }
        public bool HasAward { get; set; }
        public int Age { get; set; }

        public Actor()
        {
            this.Name = "Charlize Theron";
            this.HasAward = true;
            this.Age = 40;
        }
        public Actor(string actorName)
        {
            this.Name = actorName;
        }
        public Actor(int actorAge)
        {
            this.Age = actorAge;
        }
        public Actor(string actorName, int actorAge)
        {
            this.Name = actorName;
            this.Age = actorAge;
        }
    }
    public class IceCream
    {
        public string Flavor { get; set; }
        public int Calories { get; set; }
        public bool HasNuts { get; set; }

        public IceCream(string myFlavor,int myCalories)
        {
            this.Flavor = myFlavor;
            this.Calories = myCalories;
            this.HasNuts = false;
        }
    }


}
